#include <iostream> 
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	double mid = -1;
	int max = 0,cnt = 0;	
	for(int i=0; i<s.length(); i++){
		if( 2*mid-i>=0 && s[i]==s[2*mid-i] ){
			cnt+=2;
		}else{
			if( cnt > max ) max = cnt;
			if( i>0 && i<s.length()-1 && s[i-1]==s[i+1] ){
				mid = i;
				i++;
				cnt = 3; 
			}else if(i<s.length()-1 &&s[i]==s[i+1]){
				mid = (i+i+1)/2.0;
				i++;
				cnt = 2;
			}
		}
	}
	cout << max;
	return 0;
}
